var express = require('express');
var _ = require("underscore");
var fs = require('fs');
var gm = require('gm');//处理图片
var debug = require('debug')('routes:index');

var HomeController = require("../controllers/HomeController");
var UserController = require("../controllers/UserController");
var UserRoleController = require("../controllers/UserRoleController");
var BillingController = require("../controllers/BillingController");
var DeviceController = require("../controllers/DeviceController");
var FaultController = require("../controllers/FaultController");
var BoxController = require("../controllers/BoxController");
var PrizeController = require("../controllers/PrizeController");
var CafeGoodsController = require("../controllers/CafeGoodsController");
var CafeOrderController = require("../controllers/CafeOrderController");
var CafeCategoryController = require("../controllers/CafeCategoryController");


module.exports = function (app) {

    //管理员系统
    app.get('/', HomeController.index);//登录页
    app.get('/box_management', HomeController.main);
    app.get('/box_management/main', HomeController.main);


    //用户管理
    app.post('/user/login', UserController.login);//用户登陆
    app.get('/logout', UserController.logout);//退出登录
    app.get('/user/update_pwd', UserController.to_update_pwd);//跳转修改密码页面
    app.post('/user/update_pwd', UserController.do_update_pwd);//修改密码
    app.get('/user/list', UserController.list);
    app.get('/user/create', UserController.to_create);//新建用户
    app.post('/user/create', UserController.do_create);    //提交新用户资料
    app.get('/user/edit', UserController.to_edit);    //更新用户资料页面
    app.post('/user/edit', UserController.do_edit);    //提交更新buyer的资料
    app.get('/user/remove', UserController.remove);    //删除用户

    //角色管理
    app.get('/user/permission/tree', UserRoleController.getTree);//权限列表
    app.get('/user/role/list', UserRoleController.list);
    app.get('/user/role/ajaxlist', UserRoleController.ajax_list);
    app.get('/user/role/to/create', UserRoleController.to_create);
    app.post('/user/role/create', UserRoleController.do_create);
    app.get('/user/role/to/edit/:id', UserRoleController.to_edit);
    app.post('/user/role/edit', UserRoleController.do_edit);
    app.get('/user/role/remove/:id', UserRoleController.remove);

    //日志管理
    app.get('/system/operation_log', HomeController.log);
    app.get('/system/box_log', HomeController.fault);    //故障管理

    //故障管理
    app.get('/fault/list', FaultController.list);

    //计费管理
    app.get('/billing/list', BillingController.billing);//设置计费页面
    app.post('/billing/billing', BillingController.dobilling);//提交计费设置

    //设备管理
    app.get('/device/list', DeviceController.index);//列表页
    app.get('/device/create', DeviceController.to_create);//跳转到生成Sim卡页面
    app.post('/device/create', DeviceController.do_create);//生成sim
    app.get('/device/shake', DeviceController.to_shake);    //修改Sim卡页面
    app.post('/device/shake', DeviceController.do_shake); //修改Sim卡
    app.get('/device/wifi', DeviceController.to_wifi);//跳转至wifi设置页面
    app.post('/device/wifi', DeviceController.do_wifi);//设置wifi
    app.post('/box_management/create_sim', DeviceController.create_sim);//提交Sim卡生成
    app.get('/device/remove', DeviceController.remove);    //删除Sim卡

    //箱子实体管理
    app.get('/box/create', BoxController.to_create); //自定义生成箱子页面
    app.post('/box/create', BoxController.do_create); //箱子自定义生成
    app.get('/box/edit', BoxController.to_edit);    //编辑箱子页面
    app.post('/box/edit', BoxController.do_edit);    //提交编辑后的箱子信息
    app.get('/box/list', BoxController.list);//箱子管理列表页
    app.get('/box/doors', BoxController.doors);//门状态页面
    app.get('/box/active/list', BoxController.active_list);
    app.get('/box/active/create', BoxController.to_active_create);
    app.post('/box/active/create', BoxController.do_active_create);
    app.get('/box/active/remove', BoxController.active_remove);
    app.get('/box/prize/list', BoxController.prize_list);//绑定商品页
    app.get('/box/prize/set', BoxController.to_set);//绑定商品
    app.post('/box/prize/set', BoxController.do_set);//绑定商品提交
    app.get('/box/prize/edit', BoxController.to_prize_edit);//编辑绑定商品
    app.get('/box/probality/set', BoxController.to_probality_set);
    app.post('/box/probality/set', BoxController.do_probality_set);  //中奖率设置
    app.get('/box_management/reBinding', BoxController.reBinding);//解绑商品
    app.get('/box_management/rembox', BoxController.rembox);//删除箱子
    app.get('/box_management/box_order', BoxController.box_order);//箱子详情页面
    app.get('/box_management/boxlimit', BoxController.boxlimit);    //设置箱子中奖后是否更新开箱状态

    //商品管理
    app.get('/prize/list', PrizeController.list);
    app.get('/prize/create', PrizeController.to_create);//新建商品页面
    app.post('/prize/create', PrizeController.do_create);//创建商品提交
    app.get('/prize/edit', PrizeController.to_edit);//编辑奖品
    app.post('/prize/edit', PrizeController.do_edit);//编辑奖品提交
    app.get('/box_management/prize_order', PrizeController.prize_order);//商品详情
    app.get('/box_management/remove_prize', PrizeController.remove_prize);//删除商品卡
    app.post('/box_management/uploadimg', PrizeController.uploadimg);//上传图片

    //点单服务
    app.get('/cafe/category/list', CafeCategoryController.list);
    app.get('/cafe/category/categories', CafeCategoryController.categories);
    app.post('/cafe/category/create', CafeCategoryController.create);
    app.delete('/cafe/category/remove/:id', CafeCategoryController.remove);
    app.put('/cafe/category/edit/:id', CafeCategoryController.edit);
    app.get('/cafe/goods/list', CafeGoodsController.list);
    app.get('/cafe/goods/to/create', CafeGoodsController.to_create);
    app.post('/cafe/goods/create', CafeGoodsController.do_create);
    app.get('/cafe/goods/to/edit/:id', CafeGoodsController.to_edit);
    app.post('/cafe/goods/edit/:id', CafeGoodsController.do_edit);
    app.get('/cafe/goods/remove/:id', CafeGoodsController.remove);
    app.get('/cafe/order/list', CafeOrderController.list);
    app.get('/cafe/order/remove/:id', CafeOrderController.remove);

};